package com.cheng.example.atguigu.view2;


/**
 * 多线程问题解决
 */
public class Client11 {
    private volatile static Client11 client10;

    private Client11() {
        System.out.println(Thread.currentThread() + "\t我是构造方法Client10");
    }

    public static Client11 getInstance() {
        if (client10 == null) {
            synchronized (Client11.class) {
                if (client10 == null) {
                    client10 = new Client11();
                }
            }
        }
        return client10;
    }

    public static void main(String[] args) {
        for (int i = 0; i < 10; i++) {
            new Thread(() -> {
                Client11.getInstance();
            }).start();
        }
    }

}
